home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 August: Tool Chest / Dev.CD Aug 95 TC / Dev.CD Aug 95 TC.toast / Tool Chest / Interfaces / UniversalInterfaces 2.0 / PInterfaces / SCSI.p < prev    next >
Encoding:
Text File  |  1995-04-18  |  37.6 KB  |  936 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        SCSI.p
  3.  
  4.      Contains:    SCSI Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. }
  19.  
  20. {$IFC UNDEFINED UsingIncludes}
  21. {$SETC UsingIncludes := 0}
  22. {$ENDC}
  23.  
  24. {$IFC NOT UsingIncludes}
  25.  UNIT SCSI;
  26.  INTERFACE
  27. {$ENDC}
  28.  
  29. {$IFC UNDEFINED __SCSI__}
  30. {$SETC __SCSI__ := 1}
  31.  
  32. {$I+}
  33. {$SETC SCSIIncludes := UsingIncludes}
  34. {$SETC UsingIncludes := 1}
  35.  
  36.  
  37. {$IFC UNDEFINED __TYPES__}
  38. {$I Types.p}
  39. {$ENDC}
  40. {    ConditionalMacros.p                                            }
  41.  
  42. {$IFC UNDEFINED __MIXEDMODE__}
  43. {$I MixedMode.p}
  44. {$ENDC}
  45.  
  46. {$PUSH}
  47. {$ALIGN MAC68K}
  48. {$LibExport+}
  49.  
  50. CONST
  51.     scInc                        = 1;
  52.     scNoInc                        = 2;
  53.     scAdd                        = 3;
  54.     scMove                        = 4;
  55.     scLoop                        = 5;
  56.     scNop                        = 6;
  57.     scStop                        = 7;
  58.     scComp                        = 8;
  59.  
  60. { SCSI Manager errors }
  61.     scCommErr                    = 2;                            { communications error, operation timeout }
  62.     scArbNBErr                    = 3;                            { arbitration timeout waiting for not BSY }
  63.     scBadParmsErr                = 4;                            { bad parameter or TIB opcode }
  64.     scPhaseErr                    = 5;                            { SCSI bus not in correct phase for attempted operation }
  65.     scCompareErr                = 6;                            { data compare error }
  66.     scMgrBusyErr                = 7;                            { SCSI Manager busy  }
  67.     scSequenceErr                = 8;                            { attempted operation is out of sequence }
  68.     scBusTOErr                    = 9;                            { CPU bus timeout }
  69.     scComplPhaseErr                = 10;                            { SCSI bus wasn't in Status phase }
  70.  
  71. { Signatures }
  72.     sbSIGWord                    = $4552;                        { signature word for Block 0 ('ER') }
  73.     sbMac                        = 1;                            { system type for Mac }
  74.     pMapSIG                        = $504D;                        { partition map signature ('PM') }
  75.     pdSigWord                    = $5453;
  76.  
  77.     oldPMSigWord                = pdSigWord;
  78.     newPMSigWord                = pMapSIG;
  79.  
  80. { Driver Descriptor Map }
  81.  
  82. TYPE
  83.     Block0 = PACKED RECORD
  84.         sbSig:                    INTEGER;                                { unique value for SCSI block 0 }
  85.         sbBlkSize:                INTEGER;                                { block size of device }
  86.         sbBlkCount:                LONGINT;                                { number of blocks on device }
  87.         sbDevType:                INTEGER;                                { device type }
  88.         sbDevId:                INTEGER;                                { device id }
  89.         sbData:                    LONGINT;                                { not used }
  90.         sbDrvrCount:            INTEGER;                                { driver descriptor count }
  91.         ddBlock:                LONGINT;                                { 1st driver's starting block }
  92.         ddSize:                    INTEGER;                                { size of 1st driver (512-byte blks) }
  93.         ddType:                    INTEGER;                                { system type (1 for Mac+) }
  94.         ddPad:                    ARRAY [0..242] OF INTEGER;                { ARRAY[0..242] OF INTEGER; not used }
  95.     END;
  96.  
  97. { Partition Map Entry }
  98.     Partition = PACKED RECORD
  99.         pmSig:                    INTEGER;                                { unique value for map entry blk }
  100.         pmSigPad:                INTEGER;                                { currently unused }
  101.         pmMapBlkCnt:            LONGINT;                                { # of blks in partition map }
  102.         pmPyPartStart:            LONGINT;                                { physical start blk of partition }
  103.         pmPartBlkCnt:            LONGINT;                                { # of blks in this partition }
  104.         pmPartName:                PACKED ARRAY [0..31] OF CHAR;            { ASCII partition name }
  105.         pmParType:                PACKED ARRAY [0..31] OF CHAR;            { ASCII partition type }
  106.         pmLgDataStart:            LONGINT;                                { log. # of partition's 1st data blk }
  107.         pmDataCnt:                LONGINT;                                { # of blks in partition's data area }
  108.         pmPartStatus:            LONGINT;                                { bit field for partition status }
  109.         pmLgBootStart:            LONGINT;                                { log. blk of partition's boot code }
  110.         pmBootSize:                LONGINT;                                { number of bytes in boot code }
  111.         pmBootAddr:                LONGINT;                                { memory load address of boot code }
  112.         pmBootAddr2:            LONGINT;                                { currently unused }
  113.         pmBootEntry:            LONGINT;                                { entry point of boot code }
  114.         pmBootEntry2:            LONGINT;                                { currently unused }
  115.         pmBootCksum:            LONGINT;                                { checksum of boot code }
  116.         pmProcessor:            PACKED ARRAY [0..15] OF CHAR;            { ASCII for the processor type }
  117.         pmPad:                    ARRAY [0..187] OF INTEGER;                { 512 bytes long currently unused }
  118.     END;
  119.  
  120. { TIB instruction }
  121.     SCSIInstr = RECORD
  122.         scOpcode:                INTEGER;
  123.         scParam1:                LONGINT;
  124.         scParam2:                LONGINT;
  125.     END;
  126.  
  127.  
  128. FUNCTION SCSIReset: OSErr;
  129.     {$IFC NOT GENERATINGCFM}
  130.     INLINE $4267, $A815;
  131.     {$ENDC}
  132. FUNCTION SCSIGet: OSErr;
  133.     {$IFC NOT GENERATINGCFM}
  134.     INLINE $3F3C, $0001, $A815;
  135.     {$ENDC}
  136. FUNCTION SCSISelect(targetID: INTEGER): OSErr;
  137.     {$IFC NOT GENERATINGCFM}
  138.     INLINE $3F3C, $0002, $A815;
  139.     {$ENDC}
  140. FUNCTION SCSICmd(buffer: Ptr; count: INTEGER): OSErr;
  141.     {$IFC NOT GENERATINGCFM}
  142.     INLINE $3F3C, $0003, $A815;
  143.     {$ENDC}
  144. FUNCTION SCSIRead(tibPtr: Ptr): OSErr;
  145.     {$IFC NOT GENERATINGCFM}
  146.     INLINE $3F3C, $0005, $A815;
  147.     {$ENDC}
  148. FUNCTION SCSIRBlind(tibPtr: Ptr): OSErr;
  149.     {$IFC NOT GENERATINGCFM}
  150.     INLINE $3F3C, $0008, $A815;
  151.     {$ENDC}
  152. FUNCTION SCSIWrite(tibPtr: Ptr): OSErr;
  153.     {$IFC NOT GENERATINGCFM}
  154.     INLINE $3F3C, $0006, $A815;
  155.     {$ENDC}
  156. FUNCTION SCSIWBlind(tibPtr: Ptr): OSErr;
  157.     {$IFC NOT GENERATINGCFM}
  158.     INLINE $3F3C, $0009, $A815;
  159.     {$ENDC}
  160. FUNCTION SCSIComplete(VAR stat: INTEGER; VAR message: INTEGER; wait: LONGINT): OSErr;
  161.     {$IFC NOT GENERATINGCFM}
  162.     INLINE $3F3C, $0004, $A815;
  163.     {$ENDC}
  164. FUNCTION SCSIStat: INTEGER;
  165.     {$IFC NOT GENERATINGCFM}
  166.     INLINE $3F3C, $000A, $A815;
  167.     {$ENDC}
  168. FUNCTION SCSISelAtn(targetID: INTEGER): OSErr;
  169.     {$IFC NOT GENERATINGCFM}
  170.     INLINE $3F3C, $000B, $A815;
  171.     {$ENDC}
  172. FUNCTION SCSIMsgIn(VAR message: INTEGER): OSErr;
  173.     {$IFC NOT GENERATINGCFM}
  174.     INLINE $3F3C, $000C, $A815;
  175.     {$ENDC}
  176. FUNCTION SCSIMsgOut(message: INTEGER): OSErr;
  177.     {$IFC NOT GENERATINGCFM}
  178.     INLINE $3F3C, $000D, $A815;
  179.     {$ENDC}
  180. {——————————————————————— New SCSI Manager Interface ———————————————————————}
  181.  
  182. CONST
  183.     scsiVERSION                    = 43;
  184.  
  185. { SCSI Manager function codes }
  186.     SCSINop                        = $00;                            { Execute nothing                                         }
  187.     SCSIExecIO                    = $01;                            { Execute the specified IO                             }
  188.     SCSIBusInquiry                = $03;                            { Get parameters for entire path of HBAs                 }
  189.     SCSIReleaseQ                = $04;                            { Release the frozen SIM queue for particular LUN         }
  190.     SCSIAbortCommand            = $10;                            { Abort the selected Control Block                      }
  191.     SCSIResetBus                = $11;                            { Reset the SCSI bus                                      }
  192.     SCSIResetDevice                = $12;                            { Reset the SCSI device                                  }
  193.     SCSITerminateIO                = $13;                            { Terminate any pending IO                              }
  194.     SCSIGetVirtualIDInfo        = $80;                            { Find out which bus old ID is on                         }
  195.     SCSILoadDriver                = $82;                            { Load a driver for a device ident                     }
  196.     SCSIOldCall                    = $84;                            { XPT->SIM private call for old-API                     }
  197.     SCSICreateRefNumXref        = $85;                            { Register a DeviceIdent to drvr RefNum xref             }
  198.     SCSILookupRefNumXref        = $86;                            { Get DeviceIdent to drvr RefNum xref                     }
  199.     SCSIRemoveRefNumXref        = $87;                            { Remove a DeviceIdent to drvr RefNum xref             }
  200.     SCSIRegisterWithNewXPT        = $88;                            { XPT has changed - SIM needs to re-register itself     }
  201.     vendorUnique                = $C0;                            { 0xC0 thru 0xFF }
  202.  
  203. { SCSI Callback Procedure Prototypes }
  204. { SCSIInterruptPollProcPtr is obsolete (use SCSIInterruptProcPtr) but still here for compatibility }
  205. TYPE
  206.     SCSICallbackProcPtr = ProcPtr;  { PROCEDURE SCSICallback(scsiPB: UNIV Ptr); }
  207.     AENCallbackProcPtr = ProcPtr;  { PROCEDURE AENCallback; }
  208.     SIMInitProcPtr = ProcPtr;  { FUNCTION SIMInit(SIMinfoPtr: Ptr): OSErr; }
  209.     SIMActionProcPtr = ProcPtr;  { PROCEDURE SIMAction(scsiPB: UNIV Ptr; SIMGlobals: Ptr); }
  210.     SCSIProcPtr = ProcPtr;  { PROCEDURE SCSI; }
  211.     SCSIMakeCallbackProcPtr = ProcPtr;  { PROCEDURE SCSIMakeCallback(scsiPB: UNIV Ptr); }
  212.     SCSIInterruptPollProcPtr = ProcPtr;  { FUNCTION SCSIInterruptPoll(SIMGlobals: Ptr): LONGINT; }
  213.     SCSIInterruptProcPtr = ProcPtr;  { FUNCTION SCSIInterrupt(SIMGlobals: Ptr): LONGINT; }
  214.     SCSICallbackUPP = UniversalProcPtr;
  215.     AENCallbackUPP = UniversalProcPtr;
  216.     SIMInitUPP = UniversalProcPtr;
  217.     SIMActionUPP = UniversalProcPtr;
  218.     SCSIUPP = UniversalProcPtr;
  219.     SCSIMakeCallbackUPP = UniversalProcPtr;
  220.     SCSIInterruptPollUPP = UniversalProcPtr;
  221.     SCSIInterruptUPP = UniversalProcPtr;
  222.  
  223. CONST
  224.     uppSCSICallbackProcInfo = $000000C0; { PROCEDURE (4 byte param); }
  225.     uppAENCallbackProcInfo = $00000001; { PROCEDURE ; }
  226.     uppSIMInitProcInfo = $000000E1; { FUNCTION (4 byte param): 2 byte result; }
  227.     uppSIMActionProcInfo = $000003C1; { PROCEDURE (4 byte param, 4 byte param); }
  228.     uppSCSIProcInfo = $00000001; { PROCEDURE ; }
  229.     uppSCSIMakeCallbackProcInfo = $000000C1; { PROCEDURE (4 byte param); }
  230.     uppSCSIInterruptPollProcInfo = $000000F1; { FUNCTION (4 byte param): 4 byte result; }
  231.     uppSCSIInterruptProcInfo = $000000F1; { FUNCTION (4 byte param): 4 byte result; }
  232.  
  233. FUNCTION NewSCSICallbackProc(userRoutine: SCSICallbackProcPtr): SCSICallbackUPP;
  234.     {$IFC NOT GENERATINGCFM }
  235.     INLINE $2E9F;
  236.     {$ENDC}
  237.  
  238. FUNCTION NewAENCallbackProc(userRoutine: AENCallbackProcPtr): AENCallbackUPP;
  239.     {$IFC NOT GENERATINGCFM }
  240.     INLINE $2E9F;
  241.     {$ENDC}
  242.  
  243. FUNCTION NewSIMInitProc(userRoutine: SIMInitProcPtr): SIMInitUPP;
  244.     {$IFC NOT GENERATINGCFM }
  245.     INLINE $2E9F;
  246.     {$ENDC}
  247.  
  248. FUNCTION NewSIMActionProc(userRoutine: SIMActionProcPtr): SIMActionUPP;
  249.     {$IFC NOT GENERATINGCFM }
  250.     INLINE $2E9F;
  251.     {$ENDC}
  252.  
  253. FUNCTION NewSCSIProc(userRoutine: SCSIProcPtr): SCSIUPP;
  254.     {$IFC NOT GENERATINGCFM }
  255.     INLINE $2E9F;
  256.     {$ENDC}
  257.  
  258. FUNCTION NewSCSIMakeCallbackProc(userRoutine: SCSIMakeCallbackProcPtr): SCSIMakeCallbackUPP;
  259.     {$IFC NOT GENERATINGCFM }
  260.     INLINE $2E9F;
  261.     {$ENDC}
  262.  
  263. FUNCTION NewSCSIInterruptPollProc(userRoutine: SCSIInterruptPollProcPtr): SCSIInterruptPollUPP;
  264.     {$IFC NOT GENERATINGCFM }
  265.     INLINE $2E9F;
  266.     {$ENDC}
  267.  
  268. FUNCTION NewSCSIInterruptProc(userRoutine: SCSIInterruptProcPtr): SCSIInterruptUPP;
  269.     {$IFC NOT GENERATINGCFM }
  270.     INLINE $2E9F;
  271.     {$ENDC}
  272.  
  273. PROCEDURE CallSCSICallbackProc(scsiPB: UNIV Ptr; userRoutine: SCSICallbackUPP);
  274.     {$IFC NOT GENERATINGCFM}
  275.     INLINE $205F, $4E90;
  276.     {$ENDC}
  277.  
  278. PROCEDURE CallAENCallbackProc(userRoutine: AENCallbackUPP);
  279.     {$IFC NOT GENERATINGCFM}
  280.     INLINE $205F, $4E90;
  281.     {$ENDC}
  282.  
  283. FUNCTION CallSIMInitProc(SIMinfoPtr: Ptr; userRoutine: SIMInitUPP): OSErr;
  284.     {$IFC NOT GENERATINGCFM}
  285.     INLINE $205F, $4E90;
  286.     {$ENDC}
  287.  
  288. PROCEDURE CallSIMActionProc(scsiPB: UNIV Ptr; SIMGlobals: Ptr; userRoutine: SIMActionUPP);
  289.     {$IFC NOT GENERATINGCFM}
  290.     INLINE $205F, $4E90;
  291.     {$ENDC}
  292.  
  293. PROCEDURE CallSCSIProc(userRoutine: SCSIUPP);
  294.     {$IFC NOT GENERATINGCFM}
  295.     INLINE $205F, $4E90;
  296.     {$ENDC}
  297.  
  298. PROCEDURE CallSCSIMakeCallbackProc(scsiPB: UNIV Ptr; userRoutine: SCSIMakeCallbackUPP);
  299.     {$IFC NOT GENERATINGCFM}
  300.     INLINE $205F, $4E90;
  301.     {$ENDC}
  302.  
  303. FUNCTION CallSCSIInterruptPollProc(SIMGlobals: Ptr; userRoutine: SCSIInterruptPollUPP): LONGINT;
  304.     {$IFC NOT GENERATINGCFM}
  305.     INLINE $205F, $4E90;
  306.     {$ENDC}
  307.  
  308. FUNCTION CallSCSIInterruptProc(SIMGlobals: Ptr; userRoutine: SCSIInterruptUPP): LONGINT;
  309.     {$IFC NOT GENERATINGCFM}
  310.     INLINE $205F, $4E90;
  311.     {$ENDC}
  312.  
  313. CONST
  314.     handshakeDataLength            = 8;                            { Handshake data length }
  315.     maxCDBLength                = 16;                            { Space for the CDB bytes/pointer }
  316.     vendorIDLength                = 16;                            { ASCII string len for Vendor ID  }
  317.  
  318. { Define DeviceIdent structure }
  319.  
  320. TYPE
  321.     DeviceIdent = PACKED RECORD
  322.         diReserved:                UInt8;                                    { reserved                 }
  323.         bus:                    UInt8;                                    { SCSI - Bus Number        }
  324.         targetID:                UInt8;                                    { SCSI - Target SCSI ID    }
  325.         LUN:                    UInt8;                                    { SCSI - LUN                  }
  326.     END;
  327.  
  328. { Command Descriptor Block structure }
  329.     CDB = ARRAY [0..maxCDBLength-1] OF UInt8;
  330.  
  331.     SGRecord = RECORD
  332.         SGAddr:                    Ptr;
  333.         SGCount:                UInt32;
  334.     END;
  335.  
  336. { SCSI Phases (used by SIMs to support the Original SCSI Manager }
  337.  
  338. CONST
  339.     kDataOutPhase                = 0;                            { Encoded MSG, C/D, I/O bits }
  340.     kDataInPhase                = 1;
  341.     kCommandPhase                = 2;
  342.     kStatusPhase                = 3;
  343.     kPhaseIllegal0                = 4;
  344.     kPhaseIllegal1                = 5;
  345.     kMessageOutPhase            = 6;
  346.     kMessageInPhase                = 7;
  347.     kBusFreePhase                = 8;                            { Additional Phases }
  348.     kArbitratePhase                = 9;
  349.     kSelectPhase                = 10;
  350.     kMessageInPhaseNACK            = 11;                            { Message In Phase with ACK hanging on the bus }
  351.  
  352.  
  353. TYPE
  354.     SCSIHdr = RECORD
  355.         qLink:                    ^SCSIHdr;
  356.         scsiReserved1:            INTEGER;
  357.         scsiPBLength:            UInt16;
  358.         scsiFunctionCode:        SInt8; (* UInt8 *)
  359.         scsiReserved2:            SInt8; (* UInt8 *)
  360.         scsiResult:                OSErr;
  361.         scsiDevice:                DeviceIdent;
  362.         scsiCompletion:            SCSICallbackUPP;
  363.         scsiFlags:                UInt32;
  364.         scsiDriverStorage:        ^UInt8;
  365.         scsiXPTprivate:            Ptr;
  366.         scsiReserved3:            LONGINT;
  367.     END;
  368.  
  369.     SCSI_PB = RECORD
  370.         qLink:                    ^SCSIHdr;
  371.         scsiReserved1:            INTEGER;
  372.         scsiPBLength:            UInt16;
  373.         scsiFunctionCode:        SInt8; (* UInt8 *)
  374.         scsiReserved2:            SInt8; (* UInt8 *)
  375.         scsiResult:                OSErr;
  376.         scsiDevice:                DeviceIdent;
  377.         scsiCompletion:            SCSICallbackUPP;
  378.         scsiFlags:                UInt32;
  379.         scsiDriverStorage:        ^UInt8;
  380.         scsiXPTprivate:            Ptr;
  381.         scsiReserved3:            LONGINT;
  382.     END;
  383.  
  384.     SCSI_IO = RECORD
  385.         qLink:                    ^SCSIHdr;
  386.         scsiReserved1:            INTEGER;
  387.         scsiPBLength:            UInt16;
  388.         scsiFunctionCode:        SInt8; (* UInt8 *)
  389.         scsiReserved2:            SInt8; (* UInt8 *)
  390.         scsiResult:                OSErr;
  391.         scsiDevice:                DeviceIdent;
  392.         scsiCompletion:            SCSICallbackUPP;
  393.         scsiFlags:                UInt32;
  394.         scsiDriverStorage:        ^UInt8;
  395.         scsiXPTprivate:            Ptr;
  396.         scsiReserved3:            LONGINT;
  397.         scsiResultFlags:        UInt16;
  398.         scsiReserved3pt5:        UInt16;
  399.         scsiDataPtr:            ^UInt8;
  400.         scsiDataLength:            UInt32;
  401.         scsiSensePtr:            ^UInt8;
  402.         scsiSenseLength:        SInt8; (* UInt8 *)
  403.         scsiCDBLength:            SInt8; (* UInt8 *)
  404.         scsiSGListCount:        UInt16;
  405.         scsiReserved4:            UInt32;
  406.         scsiSCSIstatus:            SInt8; (* UInt8 *)
  407.         scsiSenseResidual:        SInt8;
  408.         scsiReserved5:            UInt16;
  409.         scsiDataResidual:        LONGINT;
  410.         scsiCDB:                CDB;
  411.         scsiTimeout:            LONGINT;
  412.         scsiReserved5pt5:        ^UInt8;
  413.         scsiReserved5pt6:        UInt16;
  414.         scsiIOFlags:            UInt16;
  415.         scsiTagAction:            SInt8; (* UInt8 *)
  416.         scsiReserved6:            SInt8; (* UInt8 *)
  417.         scsiReserved7:            UInt16;
  418.         scsiSelectTimeout:        UInt16;
  419.         scsiDataType:            SInt8; (* UInt8 *)
  420.         scsiTransferType:        SInt8; (* UInt8 *)
  421.         scsiReserved8:            UInt32;
  422.         scsiReserved9:            UInt32;
  423.         scsiHandshake:            ARRAY [0..handshakeDataLength-1] OF UInt16;
  424.         scsiReserved10:            UInt32;
  425.         scsiReserved11:            UInt32;
  426.         scsiCommandLink:        ^SCSI_IO;
  427.         scsiSIMpublics:            ARRAY [0..7] OF SInt8; (* UInt8 *)
  428.         scsiAppleReserved6:        ARRAY [0..7] OF SInt8; (* UInt8 *)
  429.         scsiCurrentPhase:        UInt16;
  430.         scsiSelector:            INTEGER;
  431.         scsiOldCallResult:        OSErr;
  432.         scsiSCSImessage:        SInt8; (* UInt8 *)
  433.         XPTprivateFlags:        SInt8; (* UInt8 *)
  434.         XPTextras:                ARRAY [0..11] OF SInt8; (* UInt8 *)
  435.     END;
  436.  
  437.     SCSIExecIOPB = SCSI_IO;
  438.  
  439. { Bus inquiry PB }
  440.     SCSIBusInquiryPB = RECORD
  441.         qLink:                    ^SCSIHdr;
  442.         scsiReserved1:            INTEGER;
  443.         scsiPBLength:            UInt16;
  444.         scsiFunctionCode:        SInt8; (* UInt8 *)
  445.         scsiReserved2:            SInt8; (* UInt8 *)
  446.         scsiResult:                OSErr;
  447.         scsiDevice:                DeviceIdent;
  448.         scsiCompletion:            SCSICallbackUPP;
  449.         scsiFlags:                UInt32;
  450.         scsiDriverStorage:        ^UInt8;
  451.         scsiXPTprivate:            Ptr;
  452.         scsiReserved3:            LONGINT;
  453.         scsiEngineCount:        UInt16;                                    { <- Number of engines on HBA                         }
  454.         scsiMaxTransferType:    UInt16;                                    { <- Number of transfer types for this HBA            }
  455.         scsiDataTypes:            UInt32;                                    { <- which data types are supported by this SIM     }
  456.         scsiIOpbSize:            UInt16;                                    { <- Size of SCSI_IO PB for this SIM/HBA             }
  457.         scsiMaxIOpbSize:        UInt16;                                    { <- Size of max SCSI_IO PB for all SIM/HBAs         }
  458.         scsiFeatureFlags:        UInt32;                                    { <- Supported features flags field                 }
  459.         scsiVersionNumber:        SInt8; (* UInt8 *)                        { <- Version number for the SIM/HBA                 }
  460.         scsiHBAInquiry:            SInt8; (* UInt8 *)                        { <- Mimic of INQ byte 7 for the HBA                 }
  461.         scsiTargetModeFlags:    SInt8; (* UInt8 *)                        { <- Flags for target mode support                 }
  462.         scsiScanFlags:            SInt8; (* UInt8 *)                        { <- Scan related feature flags                     }
  463.         scsiSIMPrivatesPtr:        UInt32;                                    { <- Ptr to SIM private data area                     }
  464.         scsiSIMPrivatesSize:    UInt32;                                    { <- Size of SIM private data area                 }
  465.         scsiAsyncFlags:            UInt32;                                    { <- Event cap. for Async Callback                 }
  466.         scsiHiBusID:            SInt8; (* UInt8 *)                        { <- Highest path ID in the subsystem              }
  467.         scsiInitiatorID:        SInt8; (* UInt8 *)                        { <- ID of the HBA on the SCSI bus                 }
  468.         scsiBIReserved0:        UInt16;                                    {                                                    }
  469.         scsiBIReserved1:        UInt32;                                    { <-                                                  }
  470.         scsiFlagsSupported:        UInt32;                                    { <- which scsiFlags are supported                 }
  471.         scsiIOFlagsSupported:    UInt16;                                    { <- which scsiIOFlags are supported                 }
  472.         scsiWeirdStuff:            UInt16;                                    { <-                                                 }
  473.         scsiMaxTarget:            UInt16;                                    { <- maximum Target number supported                 }
  474.         scsiMaxLUN:                UInt16;                                    { <- maximum Logical Unit number supported         }
  475.         scsiSIMVendor:            PACKED ARRAY [0..vendorIDLength-1] OF CHAR; { <- Vendor ID of SIM (or XPT if bus<FF)         }
  476.         scsiHBAVendor:            PACKED ARRAY [0..vendorIDLength-1] OF CHAR; { <- Vendor ID of the HBA                         }
  477.         scsiControllerFamily:    PACKED ARRAY [0..vendorIDLength-1] OF CHAR; { <- Family of SCSI Controller                 }
  478.         scsiControllerType:        PACKED ARRAY [0..vendorIDLength-1] OF CHAR; { <- Specific Model of SCSI Controller used     }
  479.         scsiXPTversion:            PACKED ARRAY [0..3] OF CHAR;            { <- version number of XPT                         }
  480.         scsiSIMversion:            PACKED ARRAY [0..3] OF CHAR;            { <- version number of SIM                         }
  481.         scsiHBAversion:            PACKED ARRAY [0..3] OF CHAR;            { <- version number of HBA                         }
  482.         scsiHBAslotType:        SInt8; (* UInt8 *)                        { <- type of "slot" that this HBA is in            }
  483.         scsiHBAslotNumber:        SInt8; (* UInt8 *)                        { <- slot number of this HBA                         }
  484.         scsiSIMsRsrcID:            UInt16;                                    { <- resource ID of this SIM                         }
  485.         scsiBIReserved3:        UInt16;                                    { <-                                                 }
  486.         scsiAdditionalLength:    UInt16;                                    { <- additional BusInquiry PB len                    }
  487.     END;
  488.  
  489. { Abort SIM Request PB }
  490.     SCSIAbortCommandPB = RECORD
  491.         qLink:                    ^SCSIHdr;
  492.         scsiReserved1:            INTEGER;
  493.         scsiPBLength:            UInt16;
  494.         scsiFunctionCode:        SInt8; (* UInt8 *)
  495.         scsiReserved2:            SInt8; (* UInt8 *)
  496.         scsiResult:                OSErr;
  497.         scsiDevice:                DeviceIdent;
  498.         scsiCompletion:            SCSICallbackUPP;
  499.         scsiFlags:                UInt32;
  500.         scsiDriverStorage:        ^UInt8;
  501.         scsiXPTprivate:            Ptr;
  502.         scsiReserved3:            LONGINT;
  503.         scsiIOptr:                ^SCSI_IO;                                { Pointer to the PB to abort                        }
  504.     END;
  505.  
  506. { Terminate I/O Process Request PB }
  507.     SCSITerminateIOPB = RECORD
  508.         qLink:                    ^SCSIHdr;
  509.         scsiReserved1:            INTEGER;
  510.         scsiPBLength:            UInt16;
  511.         scsiFunctionCode:        SInt8; (* UInt8 *)
  512.         scsiReserved2:            SInt8; (* UInt8 *)
  513.         scsiResult:                OSErr;
  514.         scsiDevice:                DeviceIdent;
  515.         scsiCompletion:            SCSICallbackUPP;
  516.         scsiFlags:                UInt32;
  517.         scsiDriverStorage:        ^UInt8;
  518.         scsiXPTprivate:            Ptr;
  519.         scsiReserved3:            LONGINT;
  520.         scsiIOptr:                ^SCSI_IO;                                { Pointer to the PB to terminate                     }
  521.     END;
  522.  
  523. { Reset SCSI Bus PB }
  524.     SCSIResetBusPB = RECORD
  525.         qLink:                    ^SCSIHdr;
  526.         scsiReserved1:            INTEGER;
  527.         scsiPBLength:            UInt16;
  528.         scsiFunctionCode:        SInt8; (* UInt8 *)
  529.         scsiReserved2:            SInt8; (* UInt8 *)
  530.         scsiResult:                OSErr;
  531.         scsiDevice:                DeviceIdent;
  532.         scsiCompletion:            SCSICallbackUPP;
  533.         scsiFlags:                UInt32;
  534.         scsiDriverStorage:        ^UInt8;
  535.         scsiXPTprivate:            Ptr;
  536.         scsiReserved3:            LONGINT;
  537.     END;
  538.  
  539. { Reset SCSI Device PB }
  540.     SCSIResetDevicePB = RECORD
  541.         qLink:                    ^SCSIHdr;
  542.         scsiReserved1:            INTEGER;
  543.         scsiPBLength:            UInt16;
  544.         scsiFunctionCode:        SInt8; (* UInt8 *)
  545.         scsiReserved2:            SInt8; (* UInt8 *)
  546.         scsiResult:                OSErr;
  547.         scsiDevice:                DeviceIdent;
  548.         scsiCompletion:            SCSICallbackUPP;
  549.         scsiFlags:                UInt32;
  550.         scsiDriverStorage:        ^UInt8;
  551.         scsiXPTprivate:            Ptr;
  552.         scsiReserved3:            LONGINT;
  553.     END;
  554.  
  555. { Release SIM Queue PB }
  556.     SCSIReleaseQPB = RECORD
  557.         qLink:                    ^SCSIHdr;
  558.         scsiReserved1:            INTEGER;
  559.         scsiPBLength:            UInt16;
  560.         scsiFunctionCode:        SInt8; (* UInt8 *)
  561.         scsiReserved2:            SInt8; (* UInt8 *)
  562.         scsiResult:                OSErr;
  563.         scsiDevice:                DeviceIdent;
  564.         scsiCompletion:            SCSICallbackUPP;
  565.         scsiFlags:                UInt32;
  566.         scsiDriverStorage:        ^UInt8;
  567.         scsiXPTprivate:            Ptr;
  568.         scsiReserved3:            LONGINT;
  569.     END;
  570.  
  571. { SCSI Get Virtual ID Info PB }
  572.     SCSIGetVirtualIDInfoPB = RECORD
  573.         qLink:                    ^SCSIHdr;
  574.         scsiReserved1:            INTEGER;
  575.         scsiPBLength:            UInt16;
  576.         scsiFunctionCode:        SInt8; (* UInt8 *)
  577.         scsiReserved2:            SInt8; (* UInt8 *)
  578.         scsiResult:                OSErr;
  579.         scsiDevice:                DeviceIdent;
  580.         scsiCompletion:            SCSICallbackUPP;
  581.         scsiFlags:                UInt32;
  582.         scsiDriverStorage:        ^UInt8;
  583.         scsiXPTprivate:            Ptr;
  584.         scsiReserved3:            LONGINT;
  585.         scsiOldCallID:            UInt16;                                    { -> SCSI ID of device in question             }
  586.         scsiExists:                BOOLEAN;                                { <- true if device exists                     }
  587.     END;
  588.  
  589. { Create/Lookup/Remove RefNum for Device PB }
  590.     SCSIDriverPB = RECORD
  591.         qLink:                    ^SCSIHdr;
  592.         scsiReserved1:            INTEGER;
  593.         scsiPBLength:            UInt16;
  594.         scsiFunctionCode:        SInt8; (* UInt8 *)
  595.         scsiReserved2:            SInt8; (* UInt8 *)
  596.         scsiResult:                OSErr;
  597.         scsiDevice:                DeviceIdent;
  598.         scsiCompletion:            SCSICallbackUPP;
  599.         scsiFlags:                UInt32;
  600.         scsiDriverStorage:        ^UInt8;
  601.         scsiXPTprivate:            Ptr;
  602.         scsiReserved3:            LONGINT;
  603.         scsiDriver:                INTEGER;                                { -> DriverRefNum, For SetDriver, <- For GetNextDriver }
  604.         scsiDriverFlags:        UInt16;                                    { <> Details of driver/device                     }
  605.         scsiNextDevice:            DeviceIdent;                            { <- DeviceIdent of the NEXT Item in the list  }
  606.     END;
  607.  
  608. { Load Driver PB }
  609.     SCSILoadDriverPB = RECORD
  610.         qLink:                    ^SCSIHdr;
  611.         scsiReserved1:            INTEGER;
  612.         scsiPBLength:            UInt16;
  613.         scsiFunctionCode:        SInt8; (* UInt8 *)
  614.         scsiReserved2:            SInt8; (* UInt8 *)
  615.         scsiResult:                OSErr;
  616.         scsiDevice:                DeviceIdent;
  617.         scsiCompletion:            SCSICallbackUPP;
  618.         scsiFlags:                UInt32;
  619.         scsiDriverStorage:        ^UInt8;
  620.         scsiXPTprivate:            Ptr;
  621.         scsiReserved3:            LONGINT;
  622.         scsiLoadedRefNum:        INTEGER;                                { <- SIM returns refnum of driver                     }
  623.         scsiDiskLoadFailed:        BOOLEAN;                                { -> if true, indicates call after failure to load }
  624.     END;
  625.  
  626. { Defines for the scsiTransferType field }
  627.  
  628. CONST
  629.     scsiTransferBlind            = 0;
  630.     scsiTransferPolled            = 1;
  631.  
  632. { Defines for the scsiDataType field }
  633.     scsiDataBuffer                = 0;                            { single contiguous buffer supplied                  }
  634.     scsiDataTIB                    = 1;                            { TIB supplied (ptr in scsiDataPtr)                 }
  635.     scsiDataSG                    = 2;                            { scatter/gather list supplied                      }
  636.  
  637. { Defines for the SCSIMgr scsiResult field in the PB header. }
  638. {  $E100 thru  E1FF }
  639. { -$1EFF thru -1E00 }
  640. { -#7935 thru -7681  }
  641. { = 0xE100 }
  642.     scsiErrorBase                = -7936;
  643.  
  644.     scsiRequestInProgress        = 1;                            { 1     = PB request is in progress             }
  645. { Execution failed  00-2F }
  646.     scsiRequestAborted            = scsiErrorBase + 2;            { -7934 = PB request aborted by the host         }
  647.     scsiUnableToAbort            = scsiErrorBase + 3;            { -7933 = Unable to Abort PB request             }
  648.     scsiNonZeroStatus            = scsiErrorBase + 4;            { -7932 = PB request completed with an err     }
  649.     scsiUnused05                = scsiErrorBase + 5;            { -7931 =                                      }
  650.     scsiUnused06                = scsiErrorBase + 6;            { -7930 =                                      }
  651.     scsiUnused07                = scsiErrorBase + 7;            { -7929 =                                      }
  652.     scsiUnused08                = scsiErrorBase + 8;            { -7928 =                                      }
  653.     scsiUnableToTerminate        = scsiErrorBase + 9;            { -7927 = Unable to Terminate I/O PB req         }
  654.     scsiSelectTimeout            = scsiErrorBase + 10;            { -7926 = Target selection timeout             }
  655.     scsiCommandTimeout            = scsiErrorBase + 11;            { -7925 = Command timeout                      }
  656.     scsiIdentifyMessageRejected    = scsiErrorBase + 12;            { -7924 =                                      }
  657.     scsiMessageRejectReceived    = scsiErrorBase + 13;            { -7923 = Message reject received                 }
  658.     scsiSCSIBusReset            = scsiErrorBase + 14;            { -7922 = SCSI bus reset sent/received         }
  659.     scsiParityError                = scsiErrorBase + 15;            { -7921 = Uncorrectable parity error occured     }
  660.     scsiAutosenseFailed            = scsiErrorBase + 16;            { -7920 = Autosense: Request sense cmd fail     }
  661.     scsiUnused11                = scsiErrorBase + 17;            { -7919 =                                      }
  662.     scsiDataRunError            = scsiErrorBase + 18;            { -7918 = Data overrun/underrun error          }
  663.     scsiUnexpectedBusFree        = scsiErrorBase + 19;            { -7917 = Unexpected BUS free                     }
  664.     scsiSequenceFailed            = scsiErrorBase + 20;            { -7916 = Target bus phase sequence failure     }
  665.     scsiWrongDirection            = scsiErrorBase + 21;            { -7915 = Data phase was in wrong direction     }
  666.     scsiUnused16                = scsiErrorBase + 22;            { -7914 =                                      }
  667.     scsiBDRsent                    = scsiErrorBase + 23;            { -7913 = A SCSI BDR msg was sent to target     }
  668.     scsiTerminated                = scsiErrorBase + 24;            { -7912 = PB request terminated by the host     }
  669.     scsiNoNexus                    = scsiErrorBase + 25;            { -7911 = Nexus is not established             }
  670.     scsiCDBReceived                = scsiErrorBase + 26;            { -7910 = The SCSI CDB has been received         }
  671. { Couldn't begin execution  30-3F }
  672.     scsiTooManyBuses            = scsiErrorBase + 48;            { -7888 = Register failed because we're full    }
  673.     scsiBusy                    = scsiErrorBase + 49;            { -7887 = SCSI subsystem is busy                 }
  674.     scsiProvideFail                = scsiErrorBase + 50;            { -7886 = Unable to provide requ. capability    }
  675.     scsiDeviceNotThere            = scsiErrorBase + 51;            { -7885 = SCSI device not installed/there      }
  676.     scsiNoHBA                    = scsiErrorBase + 52;            { -7884 = No HBA detected Error                 }
  677.     scsiDeviceConflict            = scsiErrorBase + 53;            { -7883 = sorry, max 1 refNum per DeviceIdent     }
  678.     scsiNoSuchXref                = scsiErrorBase + 54;            { -7882 = no such RefNum xref                     }
  679.     scsiQLinkInvalid            = scsiErrorBase + 55;            { -7881 = pre-linked PBs not supported            
  680.                                                                    (The QLink field was nonzero)        }
  681. { Parameter errors  40-7F }
  682.     scsiPBLengthError            = scsiErrorBase + 64;            { -7872 = (scsiPBLength is insuf'ct/invalid     }
  683.     scsiFunctionNotAvailable    = scsiErrorBase + 65;            { -7871 = The requ. func is not available      }
  684.     scsiRequestInvalid            = scsiErrorBase + 66;            { -7870 = PB request is invalid                 }
  685.     scsiBusInvalid                = scsiErrorBase + 67;            { -7869 = Bus ID supplied is invalid              }
  686.     scsiTIDInvalid                = scsiErrorBase + 68;            { -7868 = Target ID supplied is invalid         }
  687.     scsiLUNInvalid                = scsiErrorBase + 69;            { -7867 = LUN supplied is invalid              }
  688.     scsiIDInvalid                = scsiErrorBase + 70;            { -7866 = The initiator ID is invalid          }
  689.     scsiDataTypeInvalid            = scsiErrorBase + 71;            { -7865 = scsiDataType requested not supported }
  690.     scsiTransferTypeInvalid        = scsiErrorBase + 72;            { -7864 = scsiTransferType field is too high     }
  691.     scsiCDBLengthInvalid        = scsiErrorBase + 73;            { -7863 = scsiCDBLength field is too big         }
  692.  
  693.     scsiExecutionErrors            = scsiErrorBase;
  694.     scsiNotExecutedErrors        = scsiTooManyBuses;
  695.     scsiParameterErrors            = scsiPBLengthError;
  696.  
  697. { Defines for the scsiResultFlags field }
  698.     scsiSIMQFrozen                = $0001;                        { The SIM queue is frozen w/this err            }
  699.     scsiAutosenseValid            = $0002;                        { Autosense data valid for target              }
  700.     scsiBusNotFree                = $0004;                        { At time of callback, SCSI bus is not free    }
  701.  
  702. { Defines for the bit numbers of the scsiFlags field in the PB header for the SCSIExecIO function }
  703.     kbSCSIDisableAutosense        = 29;                            { Disable auto sense feature                     }
  704.     kbSCSIFlagReservedA            = 28;                            {                                              }
  705.     kbSCSIFlagReserved0            = 27;                            {                                              }
  706.     kbSCSICDBLinked                = 26;                            { The PB contains a linked CDB                    }
  707.     kbSCSIQEnable                = 25;                            { Target queue actions are enabled                }
  708.     kbSCSICDBIsPointer            = 24;                            { The CDB field contains a pointer                }
  709.     kbSCSIFlagReserved1            = 23;                            {                                                 }
  710.     kbSCSIInitiateSyncData        = 22;                            { Attempt Sync data xfer and SDTR                }
  711.     kbSCSIDisableSyncData        = 21;                            { Disable sync, go to async                    }
  712.     kbSCSISIMQHead                = 20;                            { Place PB at the head of SIM Q                }
  713.     kbSCSISIMQFreeze            = 19;                            { Return the SIM Q to frozen state                }
  714.     kbSCSISIMQNoFreeze            = 18;                            { Disallow SIM Q freezing                        }
  715.     kbSCSIDoDisconnect            = 17;                            { Definitely do disconnect                        }
  716.     kbSCSIDontDisconnect        = 16;                            { Definitely don't disconnect                    }
  717.     kbSCSIDataReadyForDMA        = 15;                            { Data buffer(s) are ready for DMA                }
  718.     kbSCSIFlagReserved3            = 14;                            {                                                 }
  719.     kbSCSIDataPhysical            = 13;                            { SG/Buffer data ptrs are physical                }
  720.     kbSCSISensePhysical            = 12;                            { Autosense buffer ptr is physical                }
  721.     kbSCSIFlagReserved5            = 11;                            {                                                 }
  722.     kbSCSIFlagReserved6            = 10;                            {                                                 }
  723.     kbSCSIFlagReserved7            = 9;                            {                                                 }
  724.     kbSCSIFlagReserved8            = 8;                            {                                                 }
  725.     kbSCSIDataBufferValid        = 7;                            { Data buffer valid                            }
  726.     kbSCSIStatusBufferValid        = 6;                            { Status buffer valid                             }
  727.     kbSCSIMessageBufferValid    = 5;                            { Message buffer valid                            }
  728.     kbSCSIFlagReserved9            = 4;                            {                                              }
  729.  
  730. { Defines for the bit masks of the scsiFlags field }
  731.     scsiDirectionMask            = $C0000000;                    { Data direction mask                        }
  732.     scsiDirectionNone            = $C0000000;                    { Data direction (11: no data)                }
  733.     scsiDirectionReserved        = $00000000;                    { Data direction (00: reserved)            }
  734.     scsiDirectionOut            = $80000000;                    { Data direction (10: DATA OUT)            }
  735.     scsiDirectionIn                = $40000000;                    { Data direction (01: DATA IN)                }
  736.     scsiDisableAutosense        = $20000000;                    { Disable auto sense feature                }
  737.     scsiFlagReservedA            = $10000000;                    {                                             }
  738.     scsiFlagReserved0            = $08000000;                    {                                             }
  739.     scsiCDBLinked                = $04000000;                    { The PB contains a linked CDB                }
  740.     scsiQEnable                    = $02000000;                    { Target queue actions are enabled            }
  741.     scsiCDBIsPointer            = $01000000;                    { The CDB field contains a pointer            }
  742.     scsiFlagReserved1            = $00800000;                    {                                             }
  743.     scsiInitiateSyncData        = $00400000;                    { Attempt Sync data xfer and SDTR            }
  744.     scsiDisableSyncData            = $00200000;                    { Disable sync, go to async                }
  745.     scsiSIMQHead                = $00100000;                    { Place PB at the head of SIM Q            }
  746.     scsiSIMQFreeze                = $00080000;                    { Return the SIM Q to frozen state            }
  747.     scsiSIMQNoFreeze            = $00040000;                    { Disallow SIM Q freezing                    }
  748.     scsiDoDisconnect            = $00020000;                    { Definitely do disconnect                    }
  749.     scsiDontDisconnect            = $00010000;                    { Definitely don't disconnect                }
  750.     scsiDataReadyForDMA            = $00008000;                    { Data buffer(s) are ready for DMA            }
  751.     scsiFlagReserved3            = $00004000;                    {  }
  752.     scsiDataPhysical            = $00002000;                    { SG/Buffer data ptrs are physical            }
  753.     scsiSensePhysical            = $00001000;                    { Autosense buffer ptr is physical            }
  754.     scsiFlagReserved5            = $00000800;                    {                                          }
  755.     scsiFlagReserved6            = $00000400;                    {                                             }
  756.     scsiFlagReserved7            = $00000200;                    {                                             }
  757.     scsiFlagReserved8            = $00000100;                    {                                             }
  758.  
  759. { bit masks for the scsiIOFlags field in SCSIExecIOPB }
  760.     scsiNoParityCheck            = $0002;                        { disable parity checking                             }
  761.     scsiDisableSelectWAtn        = $0004;                        { disable select w/Atn                              }
  762.     scsiSavePtrOnDisconnect        = $0008;                        { do SaveDataPointer upon Disconnect msg             }
  763.     scsiNoBucketIn                = $0010;                        { don’t bit bucket in during this I/O                 }
  764.     scsiNoBucketOut                = $0020;                        { don’t bit bucket out during this I/O             }
  765.     scsiDisableWide                = $0040;                        { disable wide transfer negotiation                 }
  766.     scsiInitiateWide            = $0080;                        { initiate wide transfer negotiation                 }
  767.     scsiRenegotiateSense        = $0100;                        { renegotiate sync/wide before issuing autosense     }
  768.     scsiDisableDiscipline        = $0200;                        { disable parameter checking on SCSIExecIO calls    }
  769.     scsiIOFlagReserved0080        = $0080;                        {                                                  }
  770.     scsiIOFlagReserved8000        = $8000;                        {                                                     }
  771.  
  772. { Defines for the SIM/HBA queue actions.  These values are used in the }
  773. { SCSIExecIOPB, for the queue action field. [These values should match the }
  774. { defines from some other include file for the SCSI message phases.  We may }
  775. { not need these definitions here. ] }
  776.     scsiSimpleQTag                = $20;                            { Tag for a simple queue                                 }
  777.     scsiHeadQTag                = $21;                            { Tag for head of queue                                  }
  778.     scsiOrderedQTag                = $22;                            { Tag for ordered queue                                 }
  779.  
  780. { Defines for the Bus Inquiry PB fields. }
  781. { scsiHBAInquiry field bits }
  782.     scsiBusMDP                    = $80;                            { Supports Modify Data Pointer message                        }
  783.     scsiBusWide32                = $40;                            { Supports 32 bit wide SCSI                                }
  784.     scsiBusWide16                = $20;                            { Supports 16 bit wide SCSI                                }
  785.     scsiBusSDTR                    = $10;                            { Supports Sync Data Transfer Req message                    }
  786.     scsiBusLinkedCDB            = $08;                            { Supports linked CDBs                                        }
  787.     scsiBusTagQ                    = $02;                            { Supports tag queue message                                }
  788.     scsiBusSoftReset            = $01;                            { Supports soft reset                                        }
  789.  
  790. { scsiDataTypes field bits  }
  791. {    bits 0->15 Apple-defined, 16->30 3rd-party unique, 31 = reserved }
  792.     scsiBusDataTIB                = 0+(1 * (2**(scsiDataTIB)));    { TIB supplied (ptr in scsiDataPtr)        }
  793.     scsiBusDataBuffer            = 0+(1 * (2**(scsiDataBuffer))); { single contiguous buffer supplied         }
  794.     scsiBusDataSG                = 0+(1 * (2**(scsiDataSG)));    { scatter/gather list supplied             }
  795.     scsiBusDataReserved            = $80000000;                    {                                           }
  796.  
  797. { scsiScanFlags field bits }
  798.     scsiBusScansDevices            = $80;                            { Bus scans for and maintains device list            }
  799.     scsiBusScansOnInit            = $40;                            { Bus scans performed at power-up/reboot            }
  800.     scsiBusLoadsROMDrivers        = $20;                            { may load ROM drivers to support targets             }
  801.  
  802. { scsiFeatureFlags field bits }
  803.     scsiBusInternalExternalMask    = $000000C0;                    { bus internal/external mask                    }
  804.     scsiBusInternalExternalUnknown = $00000000;                    { not known whether bus is inside or outside     }
  805.     scsiBusInternalExternal        = $000000C0;                    { bus goes inside and outside the box             }
  806.     scsiBusInternal                = $00000080;                    { bus goes inside the box                         }
  807.     scsiBusExternal                = $00000040;                    { bus goes outside the box                     }
  808.     scsiBusCacheCoherentDMA        = $00000020;                    { DMA is cache coherent                         }
  809.     scsiBusOldCallCapable        = $00000010;                    { SIM is old call capable                         }
  810.     scsiBusDifferential            = $00000004;                    { Single Ended (0) or Differential (1)         }
  811.     scsiBusFastSCSI                = $00000002;                    { HBA supports fast SCSI                         }
  812.     scsiBusDMAavailable            = $00000001;                    { DMA is available                             }
  813.  
  814. { scsiWeirdStuff field bits }
  815.     scsiOddDisconnectUnsafeRead1 = $0001;                        { Disconnects on odd byte boundries are unsafe with DMA and/or blind reads }
  816.     scsiOddDisconnectUnsafeWrite1 = $0002;                        { Disconnects on odd byte boundries are unsafe with DMA and/or blind writes }
  817.     scsiBusErrorsUnsafe            = $0004;                        { Non-handshaked delays or disconnects during blind transfers may cause a crash }
  818.     scsiRequiresHandshake        = $0008;                        { Non-handshaked delays or disconnects during blind transfers may cause data corruption }
  819.     scsiTargetDrivenSDTRSafe    = $0010;                        { Targets which initiate synchronous negotiations are supported }
  820.  
  821. { scsiHBAslotType values }
  822.     scsiMotherboardBus            = $01;                            { A built in Apple supplied bus                     }
  823.     scsiNuBus                    = $02;                            { A SIM on a NuBus card                             }
  824.     scsiPDSBus                    = $03;                            {    "  on a PDS card                                }
  825.     scsiPCIBus                    = $04;                            {    "  on a PCI bus card                            }
  826.     scsiPCMCIABus                = $05;                            {    "  on a PCMCIA card                            }
  827.     scsiFireWireBridgeBus        = $06;                            {    "  connected through a FireWire bridge        }
  828.  
  829. { Defines for the scsiDriverFlags field (in SCSIDriverPB) }
  830.     scsiDeviceSensitive            = $0001;                        { Only driver should access this device                }
  831.     scsiDeviceNoOldCallAccess    = $0002;                        { no old call access to this device                     }
  832.  
  833. {  SIMInitInfo PB }
  834. { directions are for SCSIRegisterBus call ( -> parm, <- result)             }
  835.  
  836. TYPE
  837.     SIMInitInfo = RECORD
  838.         SIMstaticPtr:            ^UInt8;                                    { <- alloc. ptr to the SIM's static vars                 }
  839.         staticSize:                LONGINT;                                { -> num bytes SIM needs for static vars                 }
  840.         SIMInit:                SIMInitUPP;                                { -> pointer to the SIM init routine                     }
  841.         SIMAction:                SIMActionUPP;                            { -> pointer to the SIM action routine                 }
  842.         SIM_ISR:                SCSIInterruptUPP;                        {       reserved                                             }
  843.         SIMInterruptPoll:        SCSIInterruptUPP;                        { -> pointer to the SIM interrupt poll routine            }
  844.         NewOldCall:                SIMActionUPP;                            { -> pointer to the SIM NewOldCall routine                }
  845.         ioPBSize:                UInt16;                                    { -> size of SCSI_IO_PBs required for this SIM            }
  846.         oldCallCapable:            BOOLEAN;                                { -> true if this SIM can handle old-API calls            }
  847.         simInfoUnused1:            SInt8; (* UInt8 *)                        {       reserved                                            }
  848.         simInternalUse:            LONGINT;                                { xx not affected or viewed by XPT                        }
  849.         XPT_ISR:                SCSIUPP;                                {    reserved                                            }
  850.         EnteringSIM:            SCSIUPP;                                { <- ptr to the EnteringSIM routine                    }
  851.         ExitingSIM:                SCSIUPP;                                { <- ptr to the ExitingSIM routine                        }
  852.         MakeCallback:            SCSIMakeCallbackUPP;                    { <- the XPT layer’s SCSIMakeCallback routine            }
  853.         busID:                    UInt16;                                    { <- bus number for the registered bus                    }
  854.         simInfoUnused3:            UInt16;                                    { <- reserved                                            }
  855.         simInfoUnused4:            LONGINT;                                { <- reserved                                            }
  856.     END;
  857.  
  858. { Glue between SCSI calls and SCSITrap format }
  859.  
  860. CONST
  861.     xptSCSIAction                = $0001;
  862.     xptSCSIRegisterBus            = $0002;
  863.     xptSCSIDeregisterBus        = $0003;
  864.     xptSCSIReregisterBus        = $0004;
  865.     xptSCSIKillXPT                = $0005;                        { kills Mini-XPT after transition }
  866.     xptSCSIInitialize            = $000A;                        { Initialize the SCSI manager }
  867.  
  868. { SCSI status}
  869.     scsiStatGood                = $00;                            { Good Status}
  870.     scsiStatCheckCondition        = $02;                            { Check Condition}
  871.     scsiStatConditionMet        = $04;                            { Condition Met}
  872.     scsiStatBusy                = $08;                            { Busy}
  873.     scsiStatIntermediate        = $10;                            { Intermediate}
  874.     scsiStatIntermedMet            = $14;                            { Intermediate - Condition Met}
  875.     scsiStatResvConflict        = $18;                            { Reservation conflict}
  876.     scsiStatTerminated            = $20;                            { Command terminated}
  877.     scsiStatQFull                = $28;                            { Queue full}
  878.  
  879. { SCSI messages}
  880.     kCmdCompleteMsg                = 0;
  881.     kExtendedMsg                = 1;                            { 0x01}
  882.     kSaveDataPointerMsg            = 2;                            { 0x02}
  883.     kRestorePointersMsg            = 3;                            { 0x03}
  884.     kDisconnectMsg                = 4;                            { 0x04}
  885.     kInitiatorDetectedErrorMsg    = 5;                            { 0x05}
  886.     kAbortMsg                    = 6;                            { 0x06}
  887.     kMsgRejectMsg                = 7;                            { 0x07}
  888.     kNoOperationMsg                = 8;                            { 0x08}
  889.     kMsgParityErrorMsg            = 9;                            { 0x09}
  890.     kLinkedCmdCompleteMsg        = 10;                            { 0x0a}
  891.     kLinkedCmdCompleteWithFlagMsg = 11;                            { 0x0b}
  892.     kBusDeviceResetMsg            = 12;                            { 0x0c}
  893.     kAbortTagMsg                = 13;                            { 0x0d}
  894.     kClearQueueMsg                = 14;                            { 0x0e}
  895.     kInitiateRecoveryMsg        = 15;                            { 0x0f}
  896.     kReleaseRecoveryMsg            = 16;                            { 0x10}
  897.     kTerminateIOProcessMsg        = 17;                            { 0x11}
  898.     kSimpleQueueTag                = $20;                            { 0x20}
  899.     kHeadOfQueueTagMsg            = 33;                            { 0x21}
  900.     kOrderedQueueTagMsg            = 34;                            { 0x22}
  901.     kIgnoreWideResidueMsg        = 35;                            { 0x23}
  902.  
  903. { moveq #kSCSIx, D0;  _SCSIAtomic }
  904.  
  905. FUNCTION SCSIAction(VAR parameterBlock: SCSI_PB): OSErr;
  906.     {$IFC NOT GENERATINGCFM}
  907.     INLINE $205F, $7001, $A089, $3E80;
  908.     {$ENDC}
  909. FUNCTION SCSIRegisterBus(VAR parameterBlock: SIMInitInfo): OSErr;
  910.     {$IFC NOT GENERATINGCFM}
  911.     INLINE $205F, $7002, $A089, $3E80;
  912.     {$ENDC}
  913. FUNCTION SCSIDeregisterBus(VAR parameterBlock: SCSI_PB): OSErr;
  914.     {$IFC NOT GENERATINGCFM}
  915.     INLINE $205F, $7003, $A089, $3E80;
  916.     {$ENDC}
  917. FUNCTION SCSIReregisterBus(VAR parameterBlock: SIMInitInfo): OSErr;
  918.     {$IFC NOT GENERATINGCFM}
  919.     INLINE $205F, $7004, $A089, $3E80;
  920.     {$ENDC}
  921. FUNCTION SCSIKillXPT(VAR parameterBlock: SIMInitInfo): OSErr;
  922.     {$IFC NOT GENERATINGCFM}
  923.     INLINE $205F, $7005, $A089, $3E80;
  924.     {$ENDC}
  925.  
  926. {$ALIGN RESET}
  927. {$POP}
  928.  
  929. {$SETC UsingIncludes := SCSIIncludes}
  930.  
  931. {$ENDC} {__SCSI__}
  932.  
  933. {$IFC NOT UsingIncludes}
  934.  END.
  935. {$ENDC}
  936.